<template>
  <DataList :cate="cate" :name="name" :cols="cols" skipExcelNumber="2" :excelHeader="excelHeader"/>
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import linq from "linq"
import { addGlxxxt, deleteGlxxxt, updateGlxxxt, getGlxxxt,bulkAddGlxxxt } from "@/api/管理信息系统.js";
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A3-4-2管理信息系统",
      name:'3.4.2 管理信息系统',
      excelHeader:{B3:"类型",C3:"系统名称",D3:"来源",E3:"开发单位名称"},
      cols: [
        { label: "类型", prop: "XZ_LX" },
        { label: "系统名称", prop: "XTMC" },
        { label: "来源", prop: "XZ_XTLY" },
        { label: "开发单位名称", prop: "KFDWMC" },
        
      ]
    };
  },
  methods: {
    getSummaries(list){
      //
        const sums = [];
         this.cols.forEach((column, index) => {
            sums[index]="";
        });
        sums[0]= "合计";
         sums[6]= "类型:"+linq.from(list).distinct("$.XZ_LX").count();
          sums[7]= "系统名称:"+linq.from(list).distinct("$.XTMC").count();
         sums[8]= "来源:"+linq.from(list).distinct("$.XZ_XTLY").count();
          sums[9]= "开发单位名称:"+linq.from(list).distinct("$.KFDWMC").count();
          sums[10]= "通过:"+linq.from(list).where("$.审核状态=='通过'").count();
            sums[10] += ",不通过:"+linq.from(list).where("$.审核状态=='不通过'").count();
            sums[10] += ",待审核:"+linq.from(list).where("$.审核状态=='待审核'").count();
       return sums;
      //
    },
    async check(array,list){
      
    },
  
    async fetchData() {
      var user = getUser();
      var datas = await getGlxxxt(user.XXID,user.CJPC);
      return datas;
    },
    onadd(model){
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
      
          console.log(JSON.stringify(temp));
          var model = await addGlxxxt(temp);
          resolve(model);
      })
    },
    
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
          
          console.log(JSON.stringify(temp));
          var model = await updateGlxxxt(temp);
          resolve(model);
      })
      //
    },
    async  bulkAdd(array){
       await  bulkAddGlxxxt({Glxxxt:array});
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
         await deleteGlxxxt(temp);
          resolve();
      })
    }
  }
};
</script>
<style>
</style>